<?php

namespace App\Model;


use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class UserAccountCancelLog extends BaseModel
{
    protected  $table = 'user_account_cancel_log';

    public function getList(Request $request)
    {
        $status = $request->input('status')??'';
        $user_id = $request->input('user_id');
        $page = $request->input('page')??1;
        $limit = $request->input('limit')??10;
        $sql = DB::connection('api')->table($this->table)
            ->leftJoin('user','user_account_cancel_log.user_id', '=','user.user_id');
            if ($user_id){
                $sql->where('user.uuid',$user_id);
            }
            if ($status != ''){
                $sql->where($this->table.'.status',$status);
            }
            $data = $sql->select('user.nickname','user.uuid',$this->table.'.*')
                ->orderByDesc('id')
                ->paginate($limit,['*'],'page',$page);

        return $this->objToArray($data);
    }
}

